<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../common/taglibs.jsp"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>${table.comment!}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${r'${ctxLayui}'}/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${r'${ctxLayui}'}/layuiadmin/style/myStyle.css" media="all">
</head>
<#assign fields = table.fields />
<body>
<div class="layui-form layui-row" lay-filter="${table.entityPath}Form" id="${table.entityPath}Form" style="padding: 20px 10px 0 0;">

    <#list fields as field>
    <#assign comment=field.comment/>
    <#assign propertyName=field.propertyName/>
    <#assign propertyType=field.propertyType/>
    <div class="layui-col-xs12 layui-col-sm6 layui-col-md6" >
        <label class="layui-form-label">${comment}<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <#if propertyName=='status'>
            <div id="${propertyName}_radio"></div>
            <#elseif propertyType=='Boolean'>
            <input type="checkbox" name="${propertyName}" lay-filter="form-switch" lay-skin="switch" lay-text="是|否">
            <#elseif propertyType=='Integer'>
            <select name="${propertyName}" lay-verify="required" id="${propertyName}" lay-filter="${propertyName}">
            </select>
            <#elseif propertyType=='LocalDateTime'>
            <input type="text" class="layui-input" id="${propertyName}-laydate" autocomplete="off" placeholder="">
            <input type="hidden" name="${propertyName}" lay-verify="required">
            <#else>
            <input type="text" name="${propertyName}" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </#if>
        </div>
    </div>
</#list>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="${table.entityPath}Form-submit" id="${table.entityPath}Form-submit" value="添加">
    </div>
</div>

<script src="${r'${ctxLayui}'}/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${r'${ctxLayui}'}/layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'form','dict','laydate','util'], function(){
        var $ = layui.$ ,form = layui.form;
        var dict = layui.dict;
        var laydate = layui.laydate;
        var util = layui.util;
        var admin = layui.admin;
        var formData = window.parent.formData;
        var id = formData?formData.id:'';
        if(!id){
            //todo
        }
        form.val("${table.entityPath}Form",$.extend({},formData));
    <#list fields as field>
        <#assign comment=field.comment/>
            <#assign propertyName=field.propertyName/>
            <#assign propertyType=field.propertyType/>
            <#if propertyName=='status'>
        dict.setRadio("${propertyName}","dict_status",formData?(formData.${propertyName}?formData.${propertyName}:1):1);
            <#elseif propertyType=='Integer'>
        dict.setSelect("${propertyName}","dict_${table.entityPath}_${propertyName}",formData.${propertyName});
            <#elseif propertyType=='Boolean'>
        dict.setSwitch("${propertyName}",formData?(formData.${propertyName}?formData.${propertyName}:0):0)
            </#if>
        </#list>
        <#list fields as field>
        <#assign comment=field.comment/>
            <#assign propertyName=field.propertyName/>
            <#assign propertyType=field.propertyType/>
            <#if propertyType=='LocalDateTime'>
        admin.renderDate("${propertyName}",formData);
    </#if>
        </#list>
        form.verify({
            v_email:admin.v_email,
            v_phone:admin.v_phone,
            v_url:admin.v_url,
            v_number:admin.v_number,
            v_date:admin.v_date,
        })
    })
</script>
</body>
</html>
